The TADS Alternate Library
Version 2.0

Time-oriented Play and Display


Copyright 2000 by Kevin Forchione.
This is part of the TADS Alternate Library Authors Manual.

Introduction and Table of Contents




Time-oriented Play and Display

 

Alt provides a powerful system for time-oriented play and display. The alt Clock class allows an author to create various timepieces that can be set and run independently of one another. The Alt gameClock object provides a means of keeping track of game time and processing complex wait commands.

 

Setting Game Date and Time

 

The story object’s initDaemon() method is the ideal place to set initial game date and time. By default the library sets the game date and time to Friday, June 17, 1887 5:00 am (C.F.Infocom’s Sherlock: The Secret of the Crown Jewels). The time-rate (the amount of time advanced between turns is 5 minutes.

 

You can modify this by using the gameClock.setClock() method. If we want to change the date and time to January 1st 2000 at noon, with a time-rate of 1 minute per turn, we would modify story thus:

 

modify story

    initDaemon = {

        notify(queue, &processQueue, 0);   

        setdaemon(turnCount, nil);  // start the turn counter daemon

        setdaemon(sleepDaemon, nil); // start the sleep daemon

        setdaemon(eatDaemon, nil);   // start the hunger daemon

        gameClock.setClock('12:00 pm', 1, 2000, 1, 01);       

    }

;

 

The first parameter is the time, in string format, including an am/pm indicator. The second parameter is the time-rate, the third is the century, followed by the month, and finally the day. The setClock() method will automatically calculate the day of the week given this information.

 

Changing the Banner Display

 

Alt’s default status line can be toggled through 3 settings using the <<banner>> command. The initial display is the Basic gameClock Banner Display, which shows the day-of-the-week and the time:

 

          Forest Clearing                   Friday, 5:00 am                 Score: 0

 

when the player enters <<banner>> the status line is toggled to the Advanced gameClock Banner Display, which shows the day-of-the-week, date, and time:

 

          Forest Clearing         Friday, 17 June 1887 5:00 am        Score: 0

 

Once more and <<banner>> produces the Classic TADS Banner Display, which shows score and turn count:

 

          Forest Clearing                                                                   0/0

 

You can set the initial banner setting by modifying the global.timeStatus attribute: Basic gameClock banner display is nil; Advanced gameClock banner display is 1; Classic TADS banner display is 2.

 

Displaying Date and Time

 

Clock class has several methods for displaying date/time information in various formats. Some examples:

 

Clock.getTime(CLOCK_TIME_HHMMTT)       returns the Clock.time in HH:MM am|pm format

Clock.getDay(CLOCK_DAY_FULL)     returns a single-quoted string of the day-of-the-week.

Clock.getDate(CLOCK_DATE_AMERICAN)    returns a single-quoted string date in mm dd yyyy format.

 

To display the game time in 24-hour military time, for instance, one would simply code the following:

 

       say(gameClock.getTime(CLOCK_TIME_HH24MM));

 

The Wait Command

 

Alt’s <<wait>> command can take various forms:

 

>wait

>wait <for> n <minutes>

>wait <for> m <hours> and n <minutes>

>wait <until> h <am|pm>

>wait <until> hh:mm <am|pm>

>wait <until> midnight|noon

 

Interrupting Waiting

 

Because time advances during a wait command in game turns, executing fuses and daemons with each advancing minute, an author might want to trigger off events that request the player to terminate a wait and address an important, time-critical situation.

 

At any point during a wait a daemon, notify, fuse, or Clock.event() can send the gameClock a stopWaiting() message.

 

For example, gameClock.stopWaiting(true) will attempt to halt the waiting process by issuing a question to the player:

 

       Do you want to continue waiting? <Y/N>

 

Answering “yes” will terminate the waiting process, while answering “no” will continue the process until either another stopWaiting() is requested or waiting has finished.

 

Under some circumstances you might wish waiting to be terminated without offering the player a choice. In these situations calling gameClock.stopWaiting(nil) will halt the waiting process without issuing the above question.

 

Under certain circumstances you might wish waiting to be uninterruptible. In these situations call gameClock.setWaitQblock(true). Any stopWaiting() requests issued during the wait will be ignored. To turn the blocking off call gameClock.setWaitQblock(nil).

 

Events

 

Clock.events() is called each time the clock is advanced. This method can be used to control time-related events such as weather simulation, sunrise/sunset, and even lighting control. You can have “Big Ben” announce the hour or control the rise and fall of tides.